<template>
  <div>
    <div>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <van-cell v-for="(item, idx) in moments" :key="idx">
          <!-- 作者 -->
          <div style="margin-bottom: 10px">
            <Author :img="item.author.avatar" :name="item.author.nick"></Author>
          </div>
          <!-- 内容 图片 评论 点赞-->
          <div style="padding-left: 30px">
            <div style="font-size: 16px">{{item.content}}</div>
            <div class="moment-imgs">
              <van-grid :column-num="3" :border="false">
                <van-grid-item v-for="(img, idx2) in item.imgs" :key="idx2">
                  <van-image :src="img" fit="cover" style="width: 100%; height: 80px"/>
                </van-grid-item>
              </van-grid>
            </div>
            <div style="margin-top: 10px; display: flex; justify-content: space-between; align-items: center">
              <div style="font-size: 14px; color: #808080">{{$util.getDateDiff(item.time)}}</div>
              <div style="display: flex; justify-content: space-between; align-items: center">
                <van-icon name="good-job-o" size="20"></van-icon>
                <van-icon name="chat-o" size="20" style="margin-left: 20px"></van-icon>
              </div>
            </div>
          </div>
        </van-cell>
      </van-list>
    </div>
  </div>
</template>

<script>
import Author from '../../components/Author'
export default {
  name: 'MomentList',
  props: ['moments'],
  components: {
    Author: Author
  },
  data () {
    return {
      list: [],
      loading: false,
      finished: false
    }
  },
  methods: {
    onLoad () {
      this.finished = true
    }
  }
}
</script>

<style scoped>
  .moment-imgs >>> .van-grid-item__content {
    padding: 2px 2px !important;
  }
</style>
